/*******************************************************************/
/* @ All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.        */
/*                                                                 */
/*  NAME      = t_rtsp_init_stmt.c                                 */
/*  NOTE      =                                                    */
/*  DATE      = 2016/02/04 by songbb                               */
/*******************************************************************/

#include <CUnit/Basic.h>
#include <stdlib.h>

#include "frcomm.h"
#include "frmem.h"

#include "../../../src/module/rtsp/config.h"
#include <rtsp/rtsp_core.h>
#include <rtsp/rtsp_header.h>
#include <rtsp/rtsp_comm.h>
#include <rtsp/rtsp_packet.h>

static int __suite_init(void)
{
    return 0;
}

static int __suite_cleanup(void)
{
    return 0;
}

static void __case1(void)
{
    L7_rtsp_stmt *p_st_rtsp_stmt = NULL;
    p_st_rtsp_stmt = (L7_rtsp_stmt *) frmalloc(sizeof(L7_rtsp_stmt));
    CU_ASSERT_PTR_NOT_NULL(p_st_rtsp_stmt);
    memset(p_st_rtsp_stmt, 0x00, sizeof(L7_rtsp_stmt));

    rtsp_init_stmt(p_st_rtsp_stmt);

    CU_ASSERT_EQUAL(p_st_rtsp_stmt->em_req_method, RTSP_METHOD_TYPE_UNKNOWN);
    CU_ASSERT_EQUAL(p_st_rtsp_stmt->st_req_end_timestamp.tv_sec, 0L);
    CU_ASSERT_EQUAL(p_st_rtsp_stmt->st_req_end_timestamp.tv_usec, 0L);
    CU_ASSERT_EQUAL(p_st_rtsp_stmt->st_resp_start_timestamp.tv_sec, 0L);
    CU_ASSERT_EQUAL(p_st_rtsp_stmt->st_resp_start_timestamp.tv_usec, 0L);
    CU_ASSERT_EQUAL(p_st_rtsp_stmt->ul_resp_server_time_us, 0L);
    CU_ASSERT_EQUAL(p_st_rtsp_stmt->ul_resp_bytes, 0L);

    rtsp_free_stmt(&p_st_rtsp_stmt);

    CU_ASSERT_PTR_NULL(p_st_rtsp_stmt);
}

int add_suite_rtsp_init_stmt(void)
{
    CU_pSuite pSuite = NULL;

    if ((pSuite = CU_add_suite(MODULE_NAME" rtsp_init_stmt()", __suite_init, __suite_cleanup)) == NULL)
        return FR_FAIL;

    if (CU_add_test(pSuite, "case1", __case1) == NULL)
        return FR_FAIL;

    return FR_SUCC;
}
